uniform sampler2D texture;

in vec4 out_color;
in vec2 out_uv;
in vec3 out_normal;
in vec3 out_eye_pos;

void main()
{
	vec4 tex=texture2D(texture,out_uv);
	float3x3 world3=float3x3(world_mtx[0].xyz,world_mtx[1].xyz,world_mtx[2].xyz);
//	float spec=saturate(dot(normalize(world3*out_normal), normalize(normalize(directional_light.xyz)-normalize(out_eye_pos))));
	float spec=saturate(dot(normalize(out_normal), normalize(normalize(directional_light.xyz)-normalize(out_eye_pos))));
	float3 directional_specular=pow(spec,17)*tex.w*float3(1,1,1);
	float directional_diffuse=saturate(0.5+0.5*dot(out_normal,normalize(directional_light.xyz)));

	gl_FragColor=vec4(tex.xyz*directional_diffuse+tex.xyz*get_light_color(out_eye_pos+cam_mtx[3].xyz,out_normal).xyz,1)*object_color*out_color;
	gl_FragColor.xyz+=directional_specular;
//	gl_FragColor=float4(1,1,1,1);
}